/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import javax.swing.JFrame;
import user.CUser;

/**
 *
 * @author Home
 */
public class Controller {

    CUser user;
    NewJFrame frame;
    NewUserDialog newUserDialog;
    UserDetailsPanel userDetailsPanel;
    ArbitratorNagotiationPanel arbitratorNagotiationPanel;
    BulletinBoardPanel bb;
    private ForumPanel forumPanel;
    NewMessageDialog newMessageDialog;
    private ForumJFrame frame1;

    public Controller() {
        this.user = new CUser();
    }

    public void init() {
        frame = new NewJFrame(this);
        newUserDialog = new NewUserDialog(frame, true, this);

        arbitratorNagotiationPanel = new ArbitratorNagotiationPanel(this);

        bb = new BulletinBoardPanel();
        frame.addTab("Arbitrators nagotiation", arbitratorNagotiationPanel);
        //frame.addTab("Forum", forumPanel);
        frame.addTab("Bulletin board", bb);
        //frame.disableTab(1);
        newUserDialog.setLocationRelativeTo(null);
        newUserDialog.setVisible(true);

    }

    public void setTabEnabled(int index) {
        frame.enableTab(index);
    }

    void setTab(int i) {
        this.frame.setTab(i);
    }

    void switchToMainFrame() {
        userDetailsPanel = new UserDetailsPanel(this);
        frame.addTab("User details", userDetailsPanel);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    void switchToNewMessagePanel() {
        newMessageDialog = new NewMessageDialog(frame, true, this);
        newMessageDialog.setLocationRelativeTo(forumPanel);
        newMessageDialog.setVisible(true);
    }

    void closeNewMessageDialog() {
        newMessageDialog.setVisible(false);
    }

    void showForum() {
        frame1 = new ForumJFrame(this);
        forumPanel = new ForumPanel(this);
        frame1.addForum(forumPanel);
        frame1.setVisible(true);

    }
}
